# coding:utf-8
import itertools


def read_file():
    try:
        f = open('information', 'r')
        lines = f.read().split('\r')
        name = lines[0].split(':')[1]
        list.append(name)

        simple_name = lines[1].split(':')[1]
        list.append(simple_name)

        family_name = lines[2].split(':')[1]
        list.append(family_name)

        phone_number = lines[3].split(':')[1]
        list.append(phone_number)

        study_number = lines[4].split(':')[1]
        list.append(study_number)

        birthday = lines[5].split(':')[1]
        list.append(birthday)

        if birthday != 'no' and birthday != 'NO':
            birthday_month_day = birthday[4:]
            birthday_year = birthday[0:4]
            list.append(birthday_month_day)
            list.append(birthday_year)
        else:
            birthday_month_day = 'no'
            birthday_year = 'no'
            list.append(birthday_month_day)
            list.append(birthday_year)

        idol_name = lines[6].split(':')[1]
        list.append(idol_name)

        idol_simple_name = lines[7].split(':')[1]
        list.append(idol_simple_name)

        father_name = lines[8].split(':')[1]
        list.append(family_name)

        father_simple_name = lines[9].split(':')[1]
        list.append(father_simple_name)

        mather_name = lines[10].split(':')[1]
        list.append(mather_name)

        mather_simple_name = lines[11].split(':')[1]
        list.append(mather_simple_name)

        son_name = lines[12].split(':')[1]
        list.append(son_name)

        son_simple_name = lines[13].split(':')[1]
        list.append(son_simple_name)

        father_birthday = lines[14].split(':')[1]
        list.append(father_birthday)

        if father_birthday != 'no' and father_birthday != 'NO':
            father_birthday_month_day = father_birthday[4:]
            father_birthday_year = father_birthday[0:4]
            list.append(father_birthday_month_day)
            list.append(father_birthday_year)
        else:
            father_birthday_month_day = 'no'
            father_birthday_year = 'no'
            list.append(father_birthday_month_day)
            list.append(father_birthday_year)

        mather_birthday = lines[15].split(':')[1]
        list.append(mather_birthday)

        if mather_birthday != 'no' and mather_birthday != 'NO':
            mather_birthday_month_day = mather_birthday[4:]
            mather_birthday_year = mather_birthday[0:4]
            list.append(mather_birthday_month_day)
            list.append(mather_birthday_year)
        else:
            mather_birthday_month_day = 'no'
            mather_birthday_year = 'no'
            list.append(mather_birthday_month_day)
            list.append(mather_birthday_year)

        son_birthday = lines[16].split(':')[1]
        list.append(son_birthday)

        if son_birthday != 'no' and son_birthday != 'NO':
            son_birthday_month_day = son_birthday[4:]
            son_birthday_year = son_birthday[0:4]
            list.append(son_birthday_month_day)
            list.append(son_birthday_year)
        else:
            son_birthday_month_day = 'no'
            son_birthday_year = 'no'
            list.append(son_birthday_month_day)
            list.append(son_birthday_year)

        address = lines[17].split(':')[1]
        list.append(address)

        university_name = lines[18].split(':')[1]
        list.append(university_name)

        university_simple_name = lines[19].split(':')[1]
        list.append(university_simple_name)

        for i in range(20, len(lines)):
            list.append(lines[i].split(':')[1])
        f.close()
    except:
        pass


def combination():
    f = open('create_key', 'w')
    for i in range(len(list)):
        if list[i] != 'no':
            if len(list[i]) >= 8:
                f.write(list[i]+'\n')

            elif len(list[i]) < 8:
                n = 8 - len(list[i])
                for j in itertools.permutations('1234567890', n):
                    f.write(list[i]+''.join(j)+'\n')

            for j in range(0, len(list)):
                if len(list[i]+list[j]) >= 8 and list[i] != 'no' and list[j] != 'no' and list[i] != list[j]:
                    f.write(list[i]+list[j]+'\n')
                    for m in range(0, len(list_special)):
                        f.write(list_special[m]+list[i] + list[j] + '\n')
                        f.write(list[i] + list_special[m] + list[j] + '\n')
                        f.write(list[i] + list[j] + list_special[m] + '\n')

            for k in range(0, 12):
                for l in range(10):
                    if len(list[i]+list_number[k][0:l]) >= 8:
                        f.write(list[i]+list_number[k][0:l]+'\n')
                        f.write(list_number[k][0:l]+list[i]+'\n')

                        for m in range(0, len(list_special)):
                            f.write(
                                list_special[m] + list[i] + list_number[k][0:l] + '\n')
                            f.write(list[i] + list_special[m] +
                                    list_number[k][0:l] + '\n')
                            f.write(list[i] + list_number[k]
                                    [0:l] + list_special[m] + '\n')
                            f.write(
                                list_special[m] + list_number[k][0:l] + list[i] + '\n')
                            f.write(list_number[k][0:l] +
                                    list_special[m] + list[i] + '\n')
                            f.write(list_number[k][0:l] +
                                    list[i] + list_special[m]+'\n')

                f.write(list[i]+list_number[k]+'\n')
                for m in range(0, len(list_special)):
                    f.write(list_special[m]+list[i] + list_number[k] + '\n')
                    f.write(list[i]+list_special[m]+list_number[k]+'\n')
                    f.write(list[i]+list_number[k]+list_special[m]+'\n')

                f.write(list_number[k]+list[i]+'\n')
                for m in range(0, len(list_special)):
                    f.write(list_special[m]+list_number[k] + list[i] + '\n')
                    f.write(list_number[k]+list_special[m]+list[i]+'\n')
                    f.write(list_number[k]+list[i]+list_special[m]+'\n')

    f.close()


def create_list_number():
    simple_number1 = '123456789'
    list_number.append(simple_number1)

    simple_number2 = '000000000'
    list_number.append(simple_number2)

    simple_number3 = '111111111'
    list_number.append(simple_number3)

    simple_number4 = '222222222'
    list_number.append(simple_number4)

    simple_number5 = '333333333'
    list_number.append(simple_number5)

    simple_number6 = '444444444'
    list_number.append(simple_number6)

    simple_number7 = '555555555'
    list_number.append(simple_number7)

    simple_number8 = '666666666'
    list_number.append(simple_number8)

    simple_number9 = '777777777'
    list_number.append(simple_number9)

    simple_number10 = '888888888'
    list_number.append(simple_number10)

    simple_number11 = '999999999'
    list_number.append(simple_number11)

    simple_number12 = '987654321'
    list_number.append(simple_number12)


def create_list_special():
    list_special.append(',')
    list_special.append('.')
    list_special.append('?')
    list_special.append('#')
    list_special.append('/')
    list_special.append(';')
    list_special.append(':')
    list_special.append('!')
    list_special.append('@')
    list_special.append('$')
    list_special.append('%')
    list_special.append('^')
    list_special.append('&')
    list_special.append('*')


def main():
    global list
    list = []
    global list_number
    list_number = []
    global list_special
    list_special = []
    create_list_special()
    create_list_number()
    read_file()
    combination()


if __name__ == '__main__':
    main()
